package com.rattsoftware.client.controllers;

import com.extjs.gxt.ui.client.event.EventType;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.google.gwt.core.client.GWT;
import com.rattsoftware.client.AppMessages;
import com.rattsoftware.client.events.AppEvents;
import com.rattsoftware.client.views.NewEditStaffView;

public class NewEditStaffController extends Controller{

	AppMessages appMessages = GWT.create(AppMessages.class);
	
	private NewEditStaffView newEditStaffView;
	
	public NewEditStaffController() {
        super();
        registerEventTypes(AppEvents.NewStaff);
        registerEventTypes(AppEvents.EditStaff);
    }
	
	public void initialize() {
		GWT.log("NewEditStaffController : initialize");
		super.initialize();
		newEditStaffView = new NewEditStaffView(this);
	}
	
	@Override
	public void handleEvent(AppEvent event) {
		GWT.log("NewEditStaffController : handleEvent");
		EventType type = (EventType) event.getType();
		if (type == AppEvents.NewStaff) {
			forwardToView(newEditStaffView, event);
		} else if (type == AppEvents.EditStaff) {
			forwardToView(newEditStaffView, event);
		}
	}
}
